#include "gtkspinbutton.h"
+#include "gtkspinbuttonprivate.h"
+
+#include "gtkaccessibleprivate.h"
#include "gtkadjustment.h"
#include "gtkbox.h"
#include "gtkbutton.h"
static void gtk_spin_button_update_width_chars (GtkSpinButton *spin_button);
+static void gtk_spin_button_accessible_init (GtkAccessibleInterface *iface);
static guint spinbutton_signals[LAST_SIGNAL] = {0};
static GParamSpec *spinbutton_props[NUM_SPINBUTTON_PROPS] = {NULL, };
G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE,
+ gtk_spin_button_accessible_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
gtk_spin_button_editable_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
iface->insert_text = gtk_spin_button_insert_text;
}
+static gboolean
+gtk_spin_button_accessible_get_platform_state (GtkAccessible *self,
+ GtkAccessiblePlatformState state)
+{
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (self);
+
+ switch (state)
+ {
+ case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE:
+ return gtk_widget_get_focusable (spin_button->entry);
+ case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED:
+ return gtk_widget_has_focus (spin_button->entry);
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+gtk_spin_button_accessible_init (GtkAccessibleInterface *iface)
+{
+ GtkAccessibleInterface *parent_iface = g_type_interface_peek_parent (iface);
+ iface->get_at_context = parent_iface->get_at_context;
+ iface->get_platform_state = gtk_spin_button_accessible_get_platform_state;
+}
+
static void
gtk_cell_editable_spin_button_activated (GtkText *text, GtkSpinButton *spin)
{
else
gtk_spin_button_set_value (spin_button, val);
}
+
+GtkText *
+gtk_spin_button_get_text_widget (GtkSpinButton *spin_button)
+{
+ return GTK_TEXT (spin_button->entry);
+}
+
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <gtk/gtkspinbutton.h>
+#include <gtk/gtktext.h>
+
+G_BEGIN_DECLS
+
+GtkText *gtk_spin_button_get_text_widget (GtkSpinButton *spin_button);
+
+G_END_DECLS